package com.weetop.akly.activity.communicationIndex;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.blankj.utilcode.util.ToastUtils;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.weetop.akly.R;
import com.weetop.akly.appConfig.GlobalConstants;
import com.weetop.akly.base.BaseActivity;
import com.weetop.akly.base.mvp.BasePresenter;
import com.weetop.akly.utils.BaseUtils;
import com.weetop.akly.utils.GlideUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.rong.imkit.RongIM;

public class UserDetailActivity extends BaseActivity {

    @BindView(R.id.rl_back)
    RelativeLayout rlBack;
    @BindView(R.id.tv_data_title)
    TextView tvDataTitle;
    @BindView(R.id.bt_tosixin)
    QMUIButton btTosixin;
    @BindView(R.id.iv_head)
    ImageView ivHead;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_account)
    TextView tvAccount;
    @BindView(R.id.tv_tel)
    TextView tvTel;
    @BindView(R.id.tv_company_tel)
    TextView tvCompanyTel;
    @BindView(R.id.tv_email)
    TextView tvEmail;
    @BindView(R.id.tv_job)
    TextView tvJob;
    private Intent intent;
    private String name;
    private int targetId;


    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_detail);
        ButterKnife.bind(this);
        QMUIStatusBarHelper.translucent(this);
        initData();
    }

    private void initData() {
        intent = getIntent();
        String account = intent.getStringExtra(GlobalConstants.Account);
        name = intent.getStringExtra(GlobalConstants.Name);
        String companyTel = intent.getStringExtra(GlobalConstants.CompanyTel);
        String email = intent.getStringExtra(GlobalConstants.Email);
        String headPhoto = intent.getStringExtra(GlobalConstants.HeadPhoto);
        String job = intent.getStringExtra(GlobalConstants.Job);
        String department = intent.getStringExtra(GlobalConstants.Department);
        String tel = intent.getStringExtra(GlobalConstants.Telephone);
        targetId = intent.getIntExtra(GlobalConstants.TargetId, -1);
        if (account.equals(myApplication.getmAccount())) {
            btTosixin.setVisibility(View.GONE);
        }
        String name1 = TextUtils.isEmpty(name) ? "无" : name;
        setTitleInfo(name1);
        GlideUtil.load(mActivity, ivHead, headPhoto, R.mipmap.headimg, R.mipmap.headimg);
        tvName.setText(name1);
        String account1 = "人员编号：" + (TextUtils.isEmpty(account) ? "无" : account);
        tvAccount.setText(account1);
        String department1 = TextUtils.isEmpty(department) ? "无" : department;
        tvJob.setText(department1);
        String tel1 = TextUtils.isEmpty(tel) ? "无" : tel;
        tvTel.setText(tel1);
        String companyTel1 = TextUtils.isEmpty(companyTel) ? "无" : companyTel;
        tvCompanyTel.setText(companyTel1);
        String email1 = TextUtils.isEmpty(email) ? "无" : email;
        tvEmail.setText(email1);
    }


    @OnClick(R.id.bt_tosixin)
    public void onViewClicked() {
        if (BaseUtils.fastClick()) {
            if (targetId != -1)
                RongIM.getInstance().startPrivateChat(mActivity, targetId + "", name);
        }
    }


}
